package com.zyd.shiro.business.enums;

/**
 * @Classname RespCode
 * @Description TODO
 * @Date 2020/6/14 8:14
 * @Created by King
 */
public enum AssetsType {
    DELETE(-2, "已删除"),
    STORAGE(-1, "未入库"),
    IDLE(1, "闲置"),
    WARE(2, "入库"),
    DISTR(3, "派发"),
    BORROW(4, "借用"),
    WITHD(5, "退库"),
    REST(6, "归还"),
    DIVERT(7, "转移"),
    TRANS(8, "调拨"),
    REPAIR(9, "维修"),
    SCRAP(10, "报废"),
    USE(11, "使用"),
    CLAIM(12, "申领");

    private Integer code;
    private String msg;

    AssetsType(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static String getMsgByCode(int code) {
        for (AssetsType assetsType : AssetsType.values()) {
            if (assetsType.getCode() == code) {
                return assetsType.getMsg();
            }
        }
        return "未知";
    }

    public static int getCodeByMsg(String msg) {
        for (AssetsType assetsType : AssetsType.values()) {
            if (assetsType.getMsg().equals(msg)) {
                return assetsType.getCode();
            }
        }
        return 0;
    }
}
